Skip to content

Conversation

@SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented Aug 15, 2025

Stack from ghstack (oldest at bottom):

  • (to be filled)

Motivation

Be able to test Vulkan lowering via optimum-executorch.

Context

Currently, ET-VK implements rotary embeddings via a custom op. This op is currently inserted into Transformer models by replacing Rotary Embedding modules with a custom module that executes the custom op via a source transform.

The source transform approach makes it cumbersome to lower LLMs to Vulkan, since it requires the export logic to apply the source transform before calling torch.export(). This in turn makes it difficult to integrate Vulkan lowering into optimum-executorch, which tries to use a common export + lowering logic for all lowering paths.

As an alternative, leverage SubgraphMatcher to detect fusable patterns and fuse the rotary embedding graph pattern into the custom op as part of the Vulkan delegate's graph passes. This removes the requirement to apply a custom source transform just for Vulkan.

Changes

  • Introduce the backends/vulkan/patterns folder to store fusable graph patterns
  • Introduce a fusable graph pattern for rotary positional embeddings
  • Update partitioner logic to automatically include nodes that are part of a fusable graph pattern
  • Introduce a pass to fuse known patterns into custom ops / custom op sequence

Differential Revision: D80293301

…instead of source transform

## Motivation

Be able to test Vulkan lowering via optimum-executorch.

## Context

Currently, ET-VK implements rotary embeddings via a custom op. This op is currently inserted into Transformer models by replacing Rotary Embedding modules with a custom module that executes the custom op via a source transform.

The source transform approach makes it cumbersome to lower LLMs to Vulkan, since it requires the export logic to apply the source transform before calling `torch.export()`. This in turn makes it difficult to integrate Vulkan lowering into optimum-executorch, which tries to use a common export + lowering logic for all lowering paths.

As an alternative, leverage `SubgraphMatcher` to detect fusable patterns and fuse the rotary embedding graph pattern into the custom op as part of the Vulkan delegate's graph passes. This removes the requirement to apply a custom source transform just for Vulkan.

## Changes

* Introduce the `backends/vulkan/patterns` folder to store fusable graph patterns
* Introduce a fusable graph pattern for rotary positional embeddings
* Update partitioner logic to automatically include nodes that are part of a fusable graph pattern
* Introduce a pass to fuse known patterns into custom ops / custom op sequence

Differential Revision: [D80293301](https://our.internmc.facebook.com/intern/diff/D80293301/)

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Aug 15, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13450

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 2 New Failures

As of commit 83b317e with merge base ecb639a (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 15, 2025
@github-actions
Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@SS-JIA SS-JIA closed this Aug 29, 2025
@SS-JIA SS-JIA deleted the gh/SS-JIA/286/head branch October 15, 2025 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant